/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Factura.java
 *
 * Created on 27/06/2011, 07:20:40 AM
 */

package GUI;
import Interfaz.InterfazControl;
import Motor.ClaseUtilitaria;
import Motor.Cliente;
import Motor.Empleado;
import Motor.Producto;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.table.DefaultTableModel;
/**
 *
 * @author Davielis
 */
public class Factura extends javax.swing.JFrame {

    /** Creates new form Factura */
	private InterfazControl laInterfaz;
	private Cliente datosCliente = new Cliente();
	//private Empleado datoEmpleado=new Empleado();

    public Factura(InterfazControl laInterfaz, Cliente cliente, List <Producto> productosSeleccionados,String sucursal,Empleado empleado)
	{
		this.laInterfaz=laInterfaz;
        initComponents();
		
		if (empleado != null)
		{
			jTCajera.setText(Integer.toString(empleado.getIdEmpleado()));
			jTSucursal.setText(empleado.getDepartamento());
		}
		else
			jTSucursal.setText(sucursal);
		datosCliente = cliente;
		jTNombreCliente.setText(cliente.getNombre());
		jTRifCi.setText(cliente.getCedula());
		jTDireccion.setText(cliente.getDireccion());
		llenarTabla(productosSeleccionados);
		this.setLocationRelativeTo(null); // Cmabiar icono de java en ventana
        this.setIconImage(new ImageIcon("src/imagenes/marketplus2.png").getImage());
		jTFecha.setText(ClaseUtilitaria.tenerFechaActual());     
    }



	  private void llenarTabla (List <Producto> productosSeleccionados)
  {
   String[] columna = {"Código", "Descripcion", "Precio" };
            DefaultTableModel dtm = new DefaultTableModel(null,columna);
   //ArrayList<Producto> Lista= this.laInterfaz.todosLosProductos();
           // ArrayList<Producto> Lista = this.laInterfaz.todosLosProductosSeleccionados();

   for (Producto pro : productosSeleccionados)
           {
    String[] row = { Integer.toString(pro.getIdProducto()) , pro.getNombreProducto(), Integer.toString(pro.getPrecioVenta() )};
                dtm.addRow(row);
           }
	jTable1.setModel(dtm);
     }




    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTFecha = new javax.swing.JTextField();
        jTCajera = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTSucursal = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTFactura = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTNombreCliente = new javax.swing.JTextField();
        jTRifCi = new javax.swing.JTextField();
        jTDireccion = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableTiposPagos = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jTTotal = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jTVuelto = new javax.swing.JTextField();
        jTTotal1 = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(390, 690));
        setResizable(false);
        getContentPane().setLayout(null);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/marketplus.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(10, 0, 94, 100);

        jLabel2.setFont(new java.awt.Font("Tempus Sans ITC", 3, 14));
        jLabel2.setText("Factura");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(170, 30, 70, 19);

        jLabel3.setText("Fecha:");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(230, 70, 40, 14);

        jLabel8.setText("Cajera:");
        getContentPane().add(jLabel8);
        jLabel8.setBounds(230, 110, 70, 20);

        jTFecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTFechaActionPerformed(evt);
            }
        });
        getContentPane().add(jTFecha);
        jTFecha.setBounds(300, 70, 70, 20);
        getContentPane().add(jTCajera);
        jTCajera.setBounds(300, 110, 70, 20);

        jLabel9.setText("Sucursal:");
        getContentPane().add(jLabel9);
        jLabel9.setBounds(10, 100, 80, 20);

        jTSucursal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTSucursalActionPerformed(evt);
            }
        });
        getContentPane().add(jTSucursal);
        jTSucursal.setBounds(10, 120, 100, 30);

        jLabel10.setText("Nro Factura:");
        getContentPane().add(jLabel10);
        jLabel10.setBounds(230, 90, 70, 14);
        getContentPane().add(jTFactura);
        jTFactura.setBounds(300, 90, 70, 20);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Código", "Descripción", "Precio"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.Float.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(10, 270, 360, 120);

        jLabel5.setText("Dirección");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(10, 220, 90, 14);

        jLabel6.setText("Nombre:");
        getContentPane().add(jLabel6);
        jLabel6.setBounds(10, 180, 70, 14);

        jLabel7.setText("RIF/CI:");
        getContentPane().add(jLabel7);
        jLabel7.setBounds(10, 200, 70, 14);
        getContentPane().add(jTNombreCliente);
        jTNombreCliente.setBounds(80, 180, 290, 20);

        jTRifCi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTRifCiActionPerformed(evt);
            }
        });
        getContentPane().add(jTRifCi);
        jTRifCi.setBounds(80, 200, 290, 20);
        getContentPane().add(jTDireccion);
        jTDireccion.setBounds(80, 220, 290, 20);

        jTableTiposPagos.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTableTiposPagos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Tarjeta", null, null},
                {"Cheque", null, null},
                {"CestaTicket", null, null},
                {"Efectivo", null, null},
                {null, null, null}
            },
            new String [] {
                "Tipo de Pagos", "Código", "Monto"
            }
        ));
        jScrollPane2.setViewportView(jTableTiposPagos);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(10, 430, 360, 90);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel4.setText("RIF: J-122231245          Desarrollado por: Group Delivery");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(50, 610, 320, 20);

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel11.setText("Total BsF:");
        getContentPane().add(jLabel11);
        jLabel11.setBounds(220, 540, 80, 14);

        jTTotal.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTTotalKeyTyped(evt);
            }
        });
        getContentPane().add(jTTotal);
        jTTotal.setBounds(290, 540, 80, 20);

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel12.setText("Vuelto BsF:");
        getContentPane().add(jLabel12);
        jLabel12.setBounds(220, 570, 90, 14);

        jTVuelto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTVueltoKeyTyped(evt);
            }
        });
        getContentPane().add(jTVuelto);
        jTVuelto.setBounds(290, 570, 80, 20);

        jTTotal1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTTotal1KeyTyped(evt);
            }
        });
        getContentPane().add(jTTotal1);
        jTTotal1.setBounds(110, 550, 80, 20);

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel13.setText("Descuento BsF:");
        getContentPane().add(jLabel13);
        jLabel13.setBounds(10, 550, 100, 14);

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel14.setText("Tipos de Pagos:");
        getContentPane().add(jLabel14);
        jLabel14.setBounds(10, 400, 90, 14);

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel15.setText("Productos:");
        getContentPane().add(jLabel15);
        jLabel15.setBounds(10, 250, 70, 14);

        pack();
    }// </editor-fold>//GEN-END:initComponents

	private void jTFechaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFechaActionPerformed
		// TODO add your handling code here:
	}//GEN-LAST:event_jTFechaActionPerformed

	private void jTSucursalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTSucursalActionPerformed
		// TODO add your handling code here:
}//GEN-LAST:event_jTSucursalActionPerformed

	private void jTRifCiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTRifCiActionPerformed
		// TODO add your handling code here:
}//GEN-LAST:event_jTRifCiActionPerformed

	private void jTTotalKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTTotalKeyTyped
		// TODO add your handling code here:
		char c = evt.getKeyChar();
		if (Character.isDigit(c)== false)
			evt.consume();
}//GEN-LAST:event_jTTotalKeyTyped

	private void jTVueltoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTVueltoKeyTyped
		// TODO add your handling code here:
		char c = evt.getKeyChar();
		if (Character.isDigit(c)== false)
			evt.consume();
}//GEN-LAST:event_jTVueltoKeyTyped

	private void jTTotal1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTTotal1KeyTyped
		// TODO add your handling code here:
	}//GEN-LAST:event_jTTotal1KeyTyped

    /**
    * @param args the command line arguments
    */
   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTCajera;
    private javax.swing.JTextField jTDireccion;
    private javax.swing.JTextField jTFactura;
    private javax.swing.JTextField jTFecha;
    private javax.swing.JTextField jTNombreCliente;
    private javax.swing.JTextField jTRifCi;
    private javax.swing.JTextField jTSucursal;
    private javax.swing.JTextField jTTotal;
    private javax.swing.JTextField jTTotal1;
    private javax.swing.JTextField jTVuelto;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTableTiposPagos;
    // End of variables declaration//GEN-END:variables

}
